﻿using System;
using SCG = System.Collections.Generic;

using Nemerle.Assertions;
using Nemerle.Utility;

using GASS.OpenCL;
using GASS.OpenCL.OpenCLDriver;

namespace Nemerle.OpenCL {

    [InfoProperty(CLImageInfo.ElementSize, int)]
    [InfoProperty(CLImageInfo.RowPitch, int, Flags(size_t))]
    [InfoProperty(CLImageInfo.SlicePitch, int, Flags(size_t))]
    [InfoProperty(CLImageInfo.Width, int, Flags(size_t))]
    [InfoProperty(CLImageInfo.Height, int, Flags(size_t))]
    [InfoProperty(CLImageInfo.Depth, int, Flags(size_t))]
    public abstract class Image : Memory {

        internal this(context : Context, create_info : ImageCreateInfo, host_ptr : object, flags : CLMemFlags) {
            base(context, host_ptr, flags);
            this.create_info = create_info;
        }

        create_info : ImageCreateInfo;

        [Accessor] mutable format : CLImageFormat;

        protected sealed override CreateHandle(host_ptr : IntPtr) : CLMem {
            format = create_info.Format;
            CreateHandle(host_ptr, ref format, create_info)
        }

        protected abstract CreateHandle(host_ptr : IntPtr, format : ref CLImageFormat, create_info : ImageCreateInfo) : CLMem;

    }

    [Record]
    public class ImageCreateInfo {

        public this() { };

        [Accessor(flags = WantSetter)] mutable format : CLImageFormat;

    }

}